﻿using Kingdee.BOS.Core.Bill;
using Kingdee.BOS.Core.DynamicForm.PlugIn;
using Kingdee.BOS.Core.DynamicForm.PlugIn.Args;
using Kingdee.BOS.Core.Metadata;
using Kingdee.BOS.Orm;
using Kingdee.BOS.Orm.DataEntity;
using Kingdee.BOS.ServiceHelper;
using Kingdee.BOS.Util;
using System.ComponentModel;

namespace HX.HxDemo.BOS.Business.PlugIn25011702
{
    [Description("【表单插件】CreateNewData"),HotUpdate]
    public class CreateNewDataFormPlugIn : AbstractDynamicFormPlugIn
    {
        public override void CreateNewData(BizDataEventArgs e)
        {
            base.CreateNewData(e);
            var billView = this.View as IBillView;
            if(billView != null && billView.OpenParameter.Status == OperationStatus.ADDNEW && billView.OpenParameter.CreateFrom != CreateFrom.Copy)
            {
                //新增币别时，始终使用人民币做初始数据
                var srcObj = BusinessDataServiceHelper.LoadSingle(this.Context, 1, this.View.BillBusinessInfo.GetDynamicObjectType());
                var obj = (DynamicObject)srcObj.Clone();
                obj["Number"] = "";
                obj["DocumentStatus"] = "A";
                e.BizDataObject = obj;
            }
        }
    }
}
